package edu.stanford.cs.cs294s;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class LocationTabWidget extends TabActivity{
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.location_info);
	    
	    String name = this.getIntent().getExtras().getString("name");
	    String facts = this.getIntent().getExtras().getString("facts");
	    String index = this.getIntent().getExtras().getString("index");
	    this.setTitle(name);

	    /*
	    TabHost mTabHost = getTabHost();
	        
	    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.textview1));
	    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2));
	    mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3));
	        
	    mTabHost.setCurrentTab(0);
	    */    
	    
	    Resources res = getResources(); // Resource object to get Drawables
	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, LocationFacts.class);
	    intent.putExtra("facts", facts);
	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("Facts").setIndicator("Facts",
	                      res.getDrawable(R.drawable.ic_tab_facts))
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    // Do the same for the other tabs
	    Intent intent2 = new Intent().setClass(this, LocationGallery.class);
	    spec = tabHost.newTabSpec("Gallery").setIndicator("Gallery",
	                      res.getDrawable(R.drawable.ic_tab_gallery))
	                  .setContent(intent2);
	    tabHost.addTab(spec);

	    Intent intent3 = new Intent().setClass(this, LocationForm.class);
	    intent3.putExtra("index", index);
	    spec = tabHost.newTabSpec("Form").setIndicator("Add Fact",
	                      res.getDrawable(R.drawable.ic_tab_form))
	                  .setContent(intent3);
	    tabHost.addTab(spec);

	    tabHost.setCurrentTab(0);
	    
	}
}
